/*******************************************************************************
 * Copyright 2011 Google Inc. All Rights Reserved.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package com.ims.equation.server.latex;

import java.util.List;
import java.util.Map;

import com.ims.equation.client.latex.LaTexRenderService;
import com.ims.equation.server.LatexRenderer;
import com.google.common.collect.Maps;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class LaTexRenderServiceImpl extends RemoteServiceServlet implements LaTexRenderService {
	private static final long serialVersionUID = -3105112915909728348L;

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String base64CodedLatexNotation(String pLaTex, float pSize) {
		return LatexRenderer.base64EncodeLaTexNotation(pLaTex, pSize);
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public Map<String,String> base64CodedLatexNotations(float pSize, List<String> pLaTexNotations) {
		if(pLaTexNotations == null){
			throw new IllegalArgumentException("The passed list may not be null.");
		}
		Map<String, String> codedNotations = Maps.newHashMap();
		
		for(String notation : pLaTexNotations){
			codedNotations.put(notation, LatexRenderer.base64EncodeLaTexNotation(notation, pSize));
		}
		
		return codedNotations;
	}
}
